/*
 * @Author: nccloud
 * @PageInfo: 复制
 */
import { ajax } from 'nc-lightapp-front';
import { AREA, URL, FIELDS, UISTATUS } from '../../constance';
import { setCardPage } from '../utils/cardPageUtil';
import { getLoginOrg } from './addBtnClick';


export default function(props, pk) {
        pk = pk ? pk : props.form.getFormItemsValue(AREA.cardFormId, FIELDS.pk_head_fields).value;
        ajax({
                url: URL.copy,
                data: pk,
                success: (res) => {
                        if (res.success && res.data) {
                                props.setUrlParam({
                                        status: UISTATUS.copy,
                                        id: pk
                                });

                                setCardPage.call(this, props, res.data, false);

                                getLoginOrg(props, AREA.cardHead, 'pk_org');//自动获取登入组织
                        }
                }
        });
}
